; Do yes do, that thing you do, so weeeelllll... (refrain)
xbutton 70 130 80 15 START
tw_stopflag = 0 ; reset abort flag
tw_lvid = $$LV.ID
lvuse dir.gc $tw_lvid
lvmulti first
if $lv_file = ""
ezreq "I would.. if I had\nsome files.." OK ""
stop
endif
if $tw_ext = 0 ; check & warn if files will be overwriten
if $tw_newdir = 0
ezreq 'With the current settings\nselected files will be\nOverWriten !\n\nIf any file is not a pure\ntext file, it may be trashed!\n\nAre you sure ?\n' "Continue|CANCEL" tw_choice
if $tw_choice = 0
stop
endif
endif
endif
guiwindow dir.wrap wait
gosub dir.wrap setup ; construct the command line
launch 1 'wrap $lv_file $tw_options' ; and launch the first file
xOnReturn 1 ; upon returning, launch the next file
lvuse dir.gc $tw_lvid
lvmulti off
if $tw_stopflag = 1 ; check if user has aborted meanwhile
guiwindow dir.wrap resume
lvdir refresh
stop
endif
lvmulti next
if $lv_file > ""
gosub dir.wrap setup
launch 1 'wrap $lv_file $tw_options'
else
guiwindow dir.wrap resume
if $tw_newdir = 1
lvdir #$tw_dest
setwintitle dir.wrap '$tw_dest '
else
lvdir refresh
endif
endif
xroutine setup ; construct the options command line
tw_options = ""
extract lv_file file tw_file
if $tw_ext = 1
extract tw_file unquote tw_file2
appvar tw_file2 .wrap ; add the file extension
tw_file = '\"$tw_file2\"'
endif
if $tw_newdir = 1
JoinFile $tw_dest $tw_file tw_file ; save to new dir
else
extract lv_file path tw_path
JoinFile $tw_path $tw_file tw_file ; or to the same dir
endif
tw_options = '$tw_file ' ; this is our correct file name